package com.company.meituan2021;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main5 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        int[] num = new int[m];

        for (int i = 0; i < m; i++) {
            num[i] = sc.nextInt();
        }
        DoubleListNode d = new DoubleListNode();
        for (int i = 0; i < m; i++) {
            d.toHead(num[i]);
        }
        d.print();

    }
}

class DoubleListNode {

    // 双向链表内部类
    class DListNode {
        int num;
        DListNode prev;
        DListNode next;

        DListNode() {
        }

        DListNode(int _num) {
            num = _num;
        }
    }

    private Map<Integer, DListNode> pos = new HashMap<>();
    private DListNode head;
    private DListNode tail;

    public DoubleListNode() {
        head = new DListNode();
        tail = new DListNode();
        head.next = tail;
        tail.prev = head;
    }

    public void toHead(int num) {
        if (!pos.containsKey(num)) {
            addToHead(num);
        } else {
            removeNode(num);
        }
    }

    // 添加到头部
    public void addToHead(int num) {

        DListNode node = new DListNode(num);
        pos.put(num, node);
        node.next = head.next;
        head.next.prev = node;
        head.next = node;
        node.prev = head;
    }

    public void removeNode(int num) {
        DListNode node = pos.get(num);
        node.prev.next = node.next;
        node.next.prev = node.prev;
        addToHead(num);
    }

    public void print() {
        for (DListNode d = head.next; d.next != null; d = d.next) {
            System.out.println(d.num);
        }
    }

}
